<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"
    import="app.Usuario"
    import="app.Propiedad"
	import="util.Translator"%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<% //Language management
	Translator t = new Translator();
	String lang = request.getParameter("lang");
	Cookie c = null;

	Cookie [] cookies = request.getCookies();
	if (cookies != null)
		for (Cookie i : cookies)
			if (i.getName().equals("vlang")) {
				c = i;
				break;
			}
	
	if (c == null)
		c = new Cookie("vlang", "en");
			
   if (lang != null) {
	   t.setLanguage(lang);
	   c.setValue(lang);
	}
	else
		t.setLanguage(c.getValue());
 
   response.addCookie(c);
%>

<% 
	// User checking management
   session = request.getSession();
   Usuario u = (Usuario)session.getAttribute("vuser");
	
   //Properties bar
   Propiedad [] properties = null;
   
   /*Just testing
   u = new Usuario();
   u.setUsuario("peter");
   u.setTipo(Usuario.ADMIN);
   */
%>

<html>
   <head>
      <link rel="stylesheet" type="text/css" href="css/regStyle.css">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title><%=t.translate("Publicar")%></title>
   </head>
   
   <body>
      <% if (u != null) {%>
	      <table class="mainTable">
	         <tr>
	            <td>
	               <a href=home.jsp><img width="100px" height="50px" src="img/logo.jpg" /></a>
	            </td>
	         </tr>
	         
	         <tr> <td><hr color="#ffa200" width="100%" size="3px"/></td> </tr>
	
	         <tr>
	            <td>
	               <form action="Publish" method="post">
	                  <table class="formTable">
	                     <tr>
	                        <td colspan="2"><%=t.translate("Tipo de propiedad")%> </td>
	                        <td colspan="2">
	                           <select name="tipoPropiedad" size="1" style="width: 100%;">
	                              <option value="1"><%=t.translate("Solar")%></option>
	                              <option value="2"><%=t.translate("Piso")%></option>
	                              <option value="3"><%=t.translate("Casa terrera")%></option>
	                              <option value="4"><%=t.translate("Local comercial")%></option>
	                           </select>
	                        </td>
	                     </tr>
	                     <tr>
	                        <td colspan="2"><%=t.translate("Tipo de oferta")%> </td>
	                        <td colspan="2">
	                           <select name="oferta" size="1" style="width: 100%;">
	                              <option value="Venta"><%=t.translate("Venta")%></option>
	                              <option value="Alquiler"><%=t.translate("Alquiler")%></option>
	                           </select>
	                        </td>
	                     </tr>
	                     <tr>
	                        <td colspan="2"><%=t.translate("Dimensiones")%></td>
	                        <td> <input type="text" name="dimension"></input> </td>
	                     </tr>
	                     <tr>
	                        <td colspan="2"><%=t.translate("Direcci&oacute;n")%></td>
	                        <td> <input type="text" name="direccion"></input> </td>
	                     </tr>
	                     <tr>
	                        <td colspan="2"><%=t.translate("Precio")%> </td>
	                        <td> <input type="text" name="precio"></input> </td>
	                     </tr>
	                     <tr>
	                        <td colspan="2"><%=t.translate("C&oacute;digo de validaci&oacute;n")%></td>
	                        <td> <input type="text" name="codigoValidacion"></input> </td>
	                     </tr>
	                     <tr>
	                        <th colspan="4" class="centerButton">
	                           <br>
	                           <input type="submit" value="<%=t.translate("publicar")%>"/>
	                        </th>
	                     </tr>
	                  </table>
	               </form>
	            </td>
	         </tr>
	      </table>
	  <%} 
      else {%>
    	  	<jsp:forward page="index.jsp"/>
    	<%}%>
   </body>
</html>